package tech.aistar.corejava.day03;

/**
 * Created by 李雨昂 on 2019/7/17.
 */
public class HomeWork {
    public static void main(String[] args) {
        //demo1(10);
        //demo2(10);
        //demo3(101,200);
        //demo4();

    }

//第一题
    public static void demo1(int n){
        for(int i = 1;i <= n;i++){
            System.out.println(i*2+"*"+i*5+"="+(i*2*i*5));
        }
    }

//第二题
   public static void demo2(int n){
       int mul = 1;
       int sum = 0;
       for(int i = 1;i <= n;i++){
            mul = mul * i;//求积
            sum = sum + mul;//求和
            System.out.println(i+"!="+mul);
        }
        for(int i = 1;i <= n;i++){
            if(i == n){
                System.out.println(i+"!="+sum);
            }else {
                System.out.print(i+"!+");
            }
        }
   }

//第三题
    public static void demo3(int a,int b){
                int flag = 0;//控制输出行数
                for(int i = a;i < b;i++){
                    int count = 0;//计数
                    for(int j = 2;j < Math.sqrt(i);j++){
                        if(i % j == 0){
                            count++;//如果能整除则不是质数count++
                            break;
                        }
                    }
                    if(count == 0){
                        if (flag == 7){
                            System.out.println();
                            flag = 0;
                        }
                flag++;
                System.out.print(i+" ");
            }
        }
    }

//第四题
    /*public static void demo4(){
        int[] arr1 = new int[]{1,2,2,1,3,2,4,5,6};
        int[] arr2 = new int[arr1.length];
        int count = 0;
        for(int i = 0;i < arr1.length;i++){
            for(int j = i;j < arr1.length;j++){
                if(arr1[i] == arr1[j]){
                    count++;
                }
            }
            if(count == 1){
                //System.out.print(arr1[i]);
                arr2[i] =arr1[i];
            }
            count = 0;
        }
        //System.out.println();
        Arrays.sort(arr2);
        for(int i = 0;i < arr2.length;i++){
            if (arr2[i] != 0){
                System.out.print(arr2[i]);
            }
        }
    }*/

}
